import os


result = []
def search(dirname, filename):
    for item in os.listdir(dirname):
        item_path = os.path.join(dirname, item)
        if os.path.isdir(item_path):
            search(item_path, filename)
        elif os.path.isfile(item_path):
            if filename in item:
                global result
                result.append(item_path.split('excel_data/')[1] +";")
                print(item_path.split('excel_data/')[1]+";")


if __name__ == '__main__':
    search(r'/Users/zhehe/PycharmProjects/testBridge/read_write_Excel/excel_data', ".xls")